<?php

/**
 * 默认控制器
 * @author scabish
 * @since 2015-11-26 16:27:04
 */
class UserController extends SCController {
        
    public function __construct() {
        parent::__construct();
    }
        
    public function Create($token) {
        Abyss::Instance()->Announce($token, [
            'api' => __METHOD__,
            'desc' => '创建用户',
            'param' => [
                [Abyss::TYPE_STRING, 'username', '用户名', 'focrs', true],
                [Abyss::TYPE_STRING, 'password', '密码', '******', true],
            ],
            'return' => [Abyss::TYPE_OBJECT, null, '用户信息', [
                [Abyss::TYPE_INTEGER, 'userId', '用户Id', 11]
            ]]
        ]);
        
        // ... save to db
        
        return ['userId' => 11];
    }
    
    public function Status($token) {
        Abyss::Instance()->Announce($token, [
            'api' => __METHOD__,
            'desc' => '获取用户状态',
            'param' => [
                [Abyss::TYPE_INTEGER, 'userId', '用户Id', 11, true]
            ],
            'return' => [Abyss::TYPE_INTEGER, null, '用户状态(0 - 未审核, 1 - 已审核)', 1]
        ]);
        
        return 1;
    }
    
    public function Address($token) {
        Abyss::Instance()->Announce($token, [
            'api' => __METHOD__,
            'desc' => '用户地址列表',
            'param' => [
                [Abyss::TYPE_INTEGER, 'userId', '用户Id', 11, true]
            ],
            'return' => [Abyss::TYPE_LIST, null, null, [
                [Abyss::TYPE_INTEGER, 'addressId', '地址Id', 1],
                [Abyss::TYPE_STRING, 'city', '城市', 'Shanghai'],
                [Abyss::TYPE_OBJECT, 'extra', '附加信息', [
                    [Abyss::TYPE_STRING, 'code', '城市编码', '00011']
                ]]
            ]]
        ]);
        
        return [
            ['addressId' => 1, 'city' => 'Shanghai', 'extra' => ['code' => '00011']],
            ['addressId' => 2, 'city' => 'Hainan', 'extra' => ['code' => '00032']],
        ];
    }
   
}